
*********************************
** Load correct visits effects:
	estimates use output/causal_visits
		global veffectp = _b[Np]
		global veffecte = _b[Ne]
*********************************



*****************************************
** Load relevant dataset & keep libraries for which all three exist

use "$datapath/intermediate/collect_robustness_sigma.dta", clear
	
	drop var1 
	gen id = 1 if raise=="Pe" 
	replace id = 2 if raise=="Pp"

	bys lno: gen Nlno = _N
	tab Nlno
	keep if Nlno==15
	distinct lno
*****************************************


*****************************************
** Keep libraries that solve to observed holding: 
	
	gen similar = (abs(Np-mNp)<.1 ) * (factor==10)
	egen SIMILAR = sum(similar), by(lno bsbottom bstop)
	tab SIMILAR if factor==10

	keep if SIMILAR==1
	
	

************************
** Drop libraries that solve to corners
	
	gen tag = mNp<1 | mNe<1
	egen TT = max(tag), by(lno bsbottom bstop)
	tab TT if raise=="Pe" & factor==10
	drop if TT==1
	

************************


***************************************************************
** Keep averages and create ratios:

	collapse (mean) CS, by(id factor raise bsbottom bstop)

			gen double x_CS = CS if factor==10
			egen double X_CS = mean(x_CS), by(bsbottom bstop)
			gen r_CS = (CS-X_CS)/X_CS
		
	keep if factor==20

		gen xr_CS = r_CS if raise=="Pe"
		egen Xr_CS = mean(xr_CS), by(bsbottom bstop)
		gen r_CS_ratio = r_CS/Xr_CS if raise=="Pp"
		
	su r_CS_ratio
	
	
	
	
	